﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using Roslyn.Compilers.CSharp;

namespace RoslynHelper
{
    public static class ObjectCreationExpression
    {
        public static ObjectCreationExpressionSyntax AddInitializers(this ObjectCreationExpressionSyntax node, IEnumerable<ExpressionSyntax> initializers)
        {
            return Syntax.ObjectCreationExpression(
                type: node.Type,
                argumentListOpt: node.ArgumentListOpt,
                initializerOpt: Syntax.InitializerExpression(
                    expressions: SeparatedList.Create<ExpressionSyntax>(
                        (node.InitializerOpt == null ? Enumerable.Empty<ExpressionSyntax>() : node.InitializerOpt.Expressions).Union(initializers))));
                            
        }
    }
}
